//
//  LoginViewController.m
//  YHChat
//
//  Created by 银河 on 2019/2/17.
//  Copyright © 2019 yinhe. All rights reserved.
//

#import "LoginViewController.h"

#import <SVProgressHUD/SVProgressHUD.h>

#import "AppDelegate.h"

#import "YHIMUIKit.h"


#define k_test01_sign   @"eJxlj11PwjAYhe-3K5beYqTttsBMvJofdAFUcCHhphlbu1WkjPa1Soj-XZ1Gm3hunyfn5JyCMAzR43R5XlbV-kUDh2MnUHgRIozO-mDXqZqXwCNT-4PirVNG8FKCMD0kSZJQjH1H1UKDkurHAGEBE4-besv7ke*CGGNCcBqNfUU1PZxdFxl7yAbPdVPhBbiMpda1WymBlZuMap3HMeTupjVOPan5Yt6whtHKxlPS3lpt89SuNnJ3x0aH1*HquJ5NBpMi6oaHq-t0vSwuvUlQO-H76DPxeORRJ4xVe90LFJOE0Ah-BQXvwQfAPF3t"

#define k_test02_sign   @"eJxlj11PgzAYhe-5FYRro2*B6mayi*FQJ1sW-IhzNw1Z32KDg1Iqgxn-uxkabeK5fZ6ck-PhuK7rPS4eTrPttnovDTO9Qs*9dD3wTv6gUpKzzLBA838QOyU1skwY1AMklFIfwHYkx9JIIX8Mg40B3*INL9gw8l0QAhAC42BkKzIf4DJOr*bXh*QlTHZdbtJ0*SqQnJV8BL0oihXcPPdtfRuH9Yxe5HU7lVFVrLsnJaer6O3OhHl7H4lNOYv3JMZa6XWySDd4mJ*Pk2Y-mViTRu7w99ExQC3aom5kVQ6CD4QSP4BjPOfT*QLcJl5g"


#define k_test03_sign   @"eJxlj0FPgzAAhe-8iqZXjbaUyvC2kakgW9wgsu3SkFHWugCFFnQa-7sZGiXxXb8v7*V9WAAAmETxVbbf111lmDkpDsEtgAhe-kGlZM4yw0ib-4P8TcmWs6wwvB0gppTaCI0dmfPKyEL*GIZrg8iI6-zIhpHvAgchjJFHJmNFHga4mG-9YOVP*51yiX9DD66TJiedbh76buk91uswquswKo6oqcpotlGvgZiGT3jWOEEnrnUYv*t1LMrl84stdTHfiXRx4en7rVDNHQmS0aSRJf99dA52R7TnrZZ1NQg2whTbBJ0DrU-rC3e6Xaw_"


@interface LoginViewController ()
@property (strong, nonatomic) IBOutlet UITextField *accuntTextField;
@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
}

- (IBAction)loginAction:(id)sender {
    [self.view endEditing:YES];
    NSString *userID = self.accuntTextField.text;
    NSString *usersign = @"";
    if ([userID isEqualToString:@"test01"]) {
        usersign = k_test01_sign;
    } else if ([userID isEqualToString:@"test02"]) {
        usersign = k_test02_sign;
    } else if ([userID isEqualToString:@"test03"]) {
        usersign = k_test03_sign;
    }
    if (!usersign || usersign.length <= 0) {
        [SVProgressHUD showInfoWithStatus:@"账号输入不正确，请输入test01、test02、test03"];
        [SVProgressHUD dismissWithDelay:2];
        return;
    }
    
    [SVProgressHUD show];
    [[YHIMUIKit sharedInstance] loginWithIdentifier:userID userSign:usersign completionBlock:^(NSError * _Nullable error) {
        [SVProgressHUD dismiss];
        if (!error) {
            [((AppDelegate *)[UIApplication sharedApplication].delegate) setMain];
            
//            [[NSUserDefaults standardUserDefaults] setObject:@[userID, usersign] forKey:@"isLogin"];
//            [[NSUserDefaults standardUserDefaults] synchronize];
        } else {
            NSString *errMsg = [NSString stringWithFormat:@"%@", error];
            [SVProgressHUD showInfoWithStatus:errMsg];
            [SVProgressHUD dismissWithDelay:2];
        }
    }];
}


@end
